package com.stu.mapper;

import com.stu.po.User;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DataMapper {
    //用户集合
    private static Map<String, User> userData = new HashMap<String, User>();
    //角色集合
    private static Map<String, List<String>> roleData = new HashMap<String, List<String>>();
    //权限集合
    private static Map<String, List<String>> permissionData = new HashMap<String, List<String>>();
    static{
        //初始化用户数据
        User u1 = new User("cg","666");
        userData.put(u1.getUsername(),u1);
        roleData.put(u1.getUsername(), Arrays.asList("seller"));
        permissionData.put(u1.getUsername(),
                Arrays.asList("customer:list","customer:save"));

        User u2 = new User("yl","888");
        userData.put(u2.getUsername(),u2);
        roleData.put(u2.getUsername(), Arrays.asList("seller","hr"));
        permissionData.put(u1.getUsername(),
                Arrays.asList("customer:list","customer:save","user:list","user:delete"));
    }
    //提供静态方法，模拟数据库返回数据
    public static User getUserByName(String username){
        return userData.get(username);
    }
    public static List<String> getRoleByName(String username){
        return roleData.get(username);
    }
    public static List<String> getPermissionByName(String username){
        return permissionData.get(username);
    }
}
